<template>
  <basic-container>
    我的项目
  </basic-container>
</template>

<script>
import {exportGeneralProjectInfoExcel,saveOrUpdateGeneralProjectInfo,saveOrUpdateGeneralProjectInfoList,saveGeneralProjectInfo,saveGeneralProjectInfoList,deleteGeneralProjectInfo,queryGeneralProjectInfo,queryGeneralProjectInfoListPage,updateGeneralProjectInfo,deleteGeneralProjectInfoList} from '@/api/general/project/generalProjectInfoApi';
import {mapGetters} from 'vuex';
import { reqCommonMsg } from '@/util/reqCommonMsg';
import {queryGeneralOrgTree} from '@/api/general/staff/generalOrgInfoApi';

export default {
  data() {
    return {
      data: [],
      // 请求参数区
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      reqParams: {
        singleBody: {},
        listBody: [{}],
        sqlCondition:[],
        orderRule: {},
        currentPage: 1,
        pageSize: 10
      },
      commonData: null,
      conditions: [],
      orderRules: [],
      singleBody: {}
    };
  },
  computed: {
    ...mapGetters(['website','userInfo','genOrgTree','permission','projectInfo']),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.general_project_i_add, false),
        viewBtn: this.vaildData(this.permission.general_project_i_view, false),
        delBtn: this.vaildData(this.permission.general_project_i_delete, false),
        editBtn: this.vaildData(this.permission.general_project_i_edit, false),
        printBtn: this.vaildData(this.permission.general_project_i_print, false),
        searchBtn:this.vaildData(this.permission.general_project_i_search, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push({id : ele.id});
      });
      return ids;
    } 
  },
  methods: { 
    /**
     * 获取树形菜单
     */
    getProjectOrgTree(){
      if(!this.projectInfo.id){
        return false;
      }
      // 加载项目组织机构树
      this.singleBody = {
        orgNo: this.projectInfo.id
      }
      this.reqParams =  {
        singleBody: this.singleBody,
        listBody: [{}],
        sqlCondition: this.conditions,
        orderRule: this.orderRules,
        currentPage: 1, 
        pageSize: 99999
      }
      this.commonData = reqCommonMsg(this.reqParams)
      queryGeneralOrgTree(this.commonData).then(res => {
        this.$store.dispatch('setProjectOrgTree', res.data.body.listBody);
      }, error => {
      });
    },
  },
  created() {
       
  },
  mounted() {
    setTimeout(() => {
      this.getProjectOrgTree();
    }, 500);
  },
  watch: {
    showColumn: {
      handler(newValue, oldValue) {
        this.$setStore({name:  this.userInfo.userId+'generalProjectInfoColumn', content: this.showColumn});
      },
      deep: true
      //this.$setStore({name: this.userInfo.userId +'generalProjectInfoColumn', content: this.showColumn});
    }
  }
};
</script>
